package com.kgc.activityprovider.service.impl;

import com.kgc.activiti.util.ResponseMsg;
import com.kgc.activityprovider.dao.CwWorkFlowMapper;
import com.kgc.activityprovider.service.WorkFlowUtilService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class SalesAdvanceRefundWorkFlowServiceImpl implements WorkFlowUtilService {

    private Logger logger= LoggerFactory.getLogger(SalesAdvanceRefundWorkFlowServiceImpl.class);

    @Autowired
    private CwWorkFlowMapper cwWorkFlowMapper;
    @Override
    public ResponseMsg changeStatus(String code, int status) {
        logger.info("SalesAdvanceRefundWorkFlowServiceImpl changeStatus params {},{}", code, status);
        ResponseMsg responseMsg=new ResponseMsg();
        int result=cwWorkFlowMapper.checkSalesAdvanceRefund(code,status);
        if(result>0){
            responseMsg.setCode("200");
        }else {
            responseMsg.setCode("201");
        }
        logger.debug("SalesAdvanceRefundWorkFlowServiceImpl changeStatus result:{}",result);
        return responseMsg;
    }

    @Override
    public ResponseMsg insertCheck(String code, Integer checkManId, String checkComment) {
        logger.info("SalesAdvanceRefundWorkFlowServiceImpl insertCheck params {},{},{}", code, checkManId, checkComment);
        ResponseMsg responseMsg=new ResponseMsg();
        int result=cwWorkFlowMapper.insertCheckSalesAdvanceRefund(code,checkManId,checkComment);
        if(result>0){
            responseMsg.setCode("200");
        }else {
            responseMsg.setCode("201");
        }
        return responseMsg;
    }

    @Override
    public ResponseMsg sendEmail(String code, String emailTo) {
        return null;
    }
}
